package com.hong.spring.common.config.condition;


import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.stereotype.Component;

/**
 * @Auther: csh
 * @Date: 2020/7/10 17:28
 * @Description:
 */
@Component
public class SystemCondition implements Condition {

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Environment environment = context.getEnvironment();
        String env_system = environment.getProperty("env_system");
        System.out.println("获取系统变量:"+env_system);
        if(env_system.equalsIgnoreCase("windows")){
            return true;
        }
        return false;
    }
}
